#include <string>
#include <iostream>
#include <zmq.hpp>
#include <thread>

int main() {
    using namespace std::chrono_literals;

    // initialize the zmq context with a single IO thread
    zmq::context_t context{1};

    // construct a REP (reply) socket and bind to interface
    zmq::socket_t socket{context, zmq::socket_type::dealer};
    socket.bind("tcp://127.0.0.1:5555");

    // prepare some static data for responses
    const std::string data{"World:"};

    for (int i = 0; i < 100; i++) {
        zmq::message_t msg;
        socket.recv(msg, zmq::recv_flags::none);
        std::cout << "Received " << msg.to_string() << std::endl;

        std::this_thread::sleep_for(1s);
        // send the reply to the client
        socket.send(zmq::buffer(data + std::to_string(i)), zmq::send_flags::dontwait);
    }

    return 0;
}